package co.edu.uniquindio.interfaz;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import co.edu.uniquindio.mundo.Retropropagacion;
import javax.swing.JButton;

public class InterfazPrincipal extends JFrame {
	
	private static final long serialVersionUID = 1L;
	private Retropropagacion retropropagacion;	
	private Recomendar panelRecomendar;
	private JButton btnEntrenar;
	
	public static void main(String[] args) {
		new InterfazPrincipal().setVisible(true);
	}
	
	public InterfazPrincipal() {
		retropropagacion = new Retropropagacion();
		initGUI();
		this.setSize(510, 600);
		this.setPreferredSize(new Dimension(510, 600));
		this.setLocationRelativeTo(null);
	}
	
	private void initGUI() {
		getContentPane().setLayout(null);
		{
			JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
			tabbedPane.setBounds(10, 11, 482, 551);
			getContentPane().add(tabbedPane);
			{
				JPanel panel = new JPanel();
				tabbedPane.addTab("Entrenar", null, panel, null);
				panel.setLayout(null);
				{
					btnEntrenar = new JButton("Entrenar");
					btnEntrenar.setBounds(158, 100, 91, 23);
					panel.add(btnEntrenar);
					btnEntrenar.addActionListener(new ActionListener() {
						@Override
						public void actionPerformed(ActionEvent arg0) {
							try {
								retropropagacion.iniciarEntrenamiento();
								JOptionPane.showMessageDialog(null, "La red ha sido entrenada");
							} catch (FileNotFoundException e) {
								e.printStackTrace();
							}
						}
					});
				}
			}
			{
				panelRecomendar = new Recomendar(this);
				panelRecomendar.setSize(new Dimension(500, 500));
				panelRecomendar.setPreferredSize(new Dimension(500, 500));
				tabbedPane.addTab("Recomendar", null, panelRecomendar, null);
			}
		}
	}

	public Retropropagacion getRetropropagacion() {
		return retropropagacion;
	}

	public void setRetropropagacion(Retropropagacion retropropagacion) {
		this.retropropagacion = retropropagacion;
	}
}
